import request from '@/utils/request'

/**
 * 例句相关API
 */
export default {
  /**
   * 获取例句列表
   * @param {Object} params - 查询参数
   * @returns {Promise}
   */
  getSentences(params) {
    return request({
      url: '/sentences',
      method: 'get',
      params
    })
  },

  /**
   * 获取例句详情
   * @param {Number|String} id - 例句ID
   * @returns {Promise}
   */
  getSentence(id) {
    return request({
      url: `/sentences/${id}`,
      method: 'get'
    })
  },

  /**
   * 创建例句
   * @param {Object} data - 例句数据
   * @returns {Promise}
   */
  createSentence(data) {
    return request({
      url: '/sentences',
      method: 'post',
      data
    })
  },

  /**
   * 更新例句
   * @param {Number|String} id - 例句ID
   * @param {Object} data - 例句数据
   * @returns {Promise}
   */
  updateSentence(id, data) {
    return request({
      url: `/sentences/${id}`,
      method: 'put',
      data
    })
  },

  /**
   * 删除例句
   * @param {Number|String} id - 例句ID
   * @returns {Promise}
   */
  deleteSentence(id) {
    return request({
      url: `/sentences/${id}`,
      method: 'delete'
    })
  },

  /**
   * 搜索例句
   * @param {Object} params - 搜索参数
   * @returns {Promise}
   */
  searchSentences(params) {
    return request({
      url: '/sentences/search',
      method: 'get',
      params
    })
  },

  /**
   * 导入例句
   * @param {Object} data - 导入数据
   * @returns {Promise}
   */
  importSentences(data) {
    return request({
      url: '/sentences/import',
      method: 'post',
      data
    })
  },

  /**
   * 导出例句
   * @param {Object} params - 导出参数
   * @returns {Promise}
   */
  exportSentences(params) {
    return request({
      url: '/sentences/export',
      method: 'get',
      params,
      responseType: 'blob' // 文件下载
    })
  },

  /**
   * 根据单词ID获取相关例句
   * @param {Number|String} wordId - 单词ID
   * @param {Object} params - 查询参数
   * @returns {Promise}
   */
  getSentencesByWord(wordId, params) {
    return request({
      url: `/words/${wordId}/sentences`,
      method: 'get',
      params
    })
  }
} 